package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.BrandService;
import com.atguigu.spzx.model.entity.system.Brand;
import com.atguigu.spzx.model.vo.common.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/admin/product/brand")
@Tag(name= "品牌管理")
public class BrandController {
    @Autowired
    private BrandService brandService;
    @GetMapping("{page}/{limit}")
    @Operation(summary = "获取品牌列表")
    public Result<PageInfo<Brand>> findByPage(@PathVariable Integer page,@PathVariable Integer limit){
        PageInfo<Brand> pageInfo = brandService.findByPage(page,limit);
        return Result.OK(pageInfo);
    }

    @PostMapping("/AddBrand")
    @Operation(summary = "新增品牌")
    public Result<Brand> addBrand (@RequestBody Brand brand){
        brandService.addBrand(brand);
        return Result.OK();
    }

    @DeleteMapping("/delbrabd")
    @Operation(summary = "删除品牌")
    public Result<Brand> delBrand (Brand brand){
        brandService.delBrand(brand);
        return Result.OK();
    }

    @PutMapping("/updataById")
    @Operation(summary = "修改品牌")
    public Result<Brand> updateById(@RequestBody Brand brand){
        brandService.updaeById(brand);
        return Result.OK();
    }



}
